<?php
namespace app\common\model;

use think\Db;
use think\Model;

/**   YSF
 *    Date: 2018/8/20
 *    主板管理 Model
 * Class MainboardModel
 * @package app\common\model
 */
class MainboardModel extends Model
{
    // 表名
    protected $dbName = 'mainboard';

    // 列表查询
    public function getAll($where=[], $field='*', $page=1, $pageSize=1000, $order='create_time DESC')
    {
        $result = Db::name($this->dbName)
                    ->where($where)
                    ->field($field)
                    ->page($page, $pageSize)
                    ->order($order)
                    ->select();
        return $result;
    }

    // 数量获取
    public function getCount($where=[])
    {
        $result = Db::name($this->dbName)
                    ->where($where)
                    ->count();
        return $result;
    }

    // 添加操作
    public function add($data=[])
    {
        $result = Db::name($this->dbName)->insertGetId($data);
        return $result;
    }

    // 单条查询
    public function getOne($where=[], $field='*')
    {
        $result = Db::name($this->dbName)
                    ->where($where)
                    ->field($field)
                    ->find();
        return $result;
    }

    // 修改操作
    public function edit($where=[], $data=[])
    {
        $result = Db::name($this->dbName)
                    ->where($where)
                    ->update($data);
        return $result;
    }

}